$OpenBSD: patch-client_dhcpc_subr_c,v 1.2 2013/05/10 10:45:46 sthen Exp $
--- client/dhcpc_subr.c.orig	Thu Sep 10 01:06:39 1998
+++ client/dhcpc_subr.c	Fri May 10 11:27:24 2013
@@ -1110,7 +1110,12 @@ initialize(ifp)
 #ifndef LOG_PERROR
 #define LOG_PERROR   0
 #endif
+#ifndef __OpenBSD__
   openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL0);
+#else
+  /* Using LOG_LOCAL1 to avoid OpenBSD ipmon log conflict */
+  openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL1);
+#endif
 
   sprintf(pid_filename, "%s.%s.pid", PATH_PID_PREFIX, ifp->name);
   sprintf(cache_filename, "%s.%s", PATH_CACHE_PREFIX, ifp->name);
@@ -1314,7 +1319,13 @@ initialize(ifp)
 #ifndef LOG_PERROR
 #define LOG_PERROR   0
 #endif
+
+#ifndef __OpenBSD__
   openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL0);
+#else
+  /* Using LOG_LOCAL1 to avoid OpenBSD ipmon log conflict */
+  openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL1);
+#endif
 
   sprintf(pid_filename, "%s.%s.pid", PATH_PID_PREFIX, ifp->name);
   sprintf(cache_filename, "%s.%s", PATH_CACHE_PREFIX, ifp->name);
@@ -1500,7 +1511,7 @@ initialize(ifp)
 /*
  * halt network, and reset the interface
  */
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 
 void
 reset_if(ifp, updown)
@@ -1551,7 +1562,7 @@ reset_if(ifp, updown)
 #endif
 
 
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 /*
  * ifconfig up/down
  */
@@ -1623,7 +1634,7 @@ updown_if(ifp, updown)
  * configure network interface
  *    address, netmask, and broadcast address
  */
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 
 int
 config_if(ifp, addr, mask, brdcst)
@@ -1704,7 +1715,7 @@ config_if(ifp, addr, mask, brdcst)
   return(0);
 }
 
-#else /* not __bsdi__ nor __FreeBSD__ */
+#else /* not __bsdi__ not __FreeBSD__ nor __OpenBSD__ */
 
 int
 config_if(ifp, addr, mask, brdcst)
@@ -1745,22 +1756,22 @@ config_if(ifp, addr, mask, brdcst)
   }
 
   flushroutes(ifp->name);
-  if (mask != NULL) {
+  if (addr != NULL) {
     bzero(&ifr, sizeof(struct ifreq));
     strcpy(ifr.ifr_name, ifp->name);
     ((struct sockaddr_in *) &ifr.ifr_addr)->sin_family = AF_INET;
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = mask->s_addr;
-    if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
+    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = addr->s_addr;
+    if (ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
       close(sockfd);
       return(-1);
     }
   }
-  if (addr != NULL) {
+  if (mask != NULL) {
     bzero(&ifr, sizeof(struct ifreq));
     strcpy(ifr.ifr_name, ifp->name);
     ((struct sockaddr_in *) &ifr.ifr_addr)->sin_family = AF_INET;
-    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = addr->s_addr;
-    if (ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
+    ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = mask->s_addr;
+    if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
       close(sockfd);
       return(-1);
     }
@@ -1780,19 +1791,19 @@ config_if(ifp, addr, mask, brdcst)
   return(0);
 }
 
-#endif /* defined(__bsdi__) || defined(__FreeBSD__) */
+#endif /* defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__) */
 
 
 /*
  * set routing table
  */
-#if !defined(__bsdi__) && !defined(__FreeBSD__)
+#if !defined(__bsdi__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
 void
 set_route(param)
   struct dhcp_param *param;
 {
   int sockfd = 0;
-#if !defined(__bsdi__) && !defined(__FreeBSD__) && !defined(__osf__)
+#if !defined(__bsdi__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__osf__)
 #define  ortentry  rtentry
 #endif
   struct ortentry rt;
@@ -1816,12 +1827,12 @@ set_route(param)
     bzero(&dst, sizeof(struct sockaddr));
     bzero(&gateway, sizeof(struct sockaddr));
     rt.rt_flags = RTF_UP | RTF_GATEWAY;
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
     ((struct sockaddr_in *) &dst)->sin_len = sizeof(struct sockaddr_in);
 #endif
     ((struct sockaddr_in *) &dst)->sin_family = AF_INET;
     ((struct sockaddr_in *) &dst)->sin_addr.s_addr = INADDR_ANY;
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
     ((struct sockaddr_in *) &gateway)->sin_len = sizeof(struct sockaddr_in);
 #endif
     ((struct sockaddr_in *) &gateway)->sin_family = AF_INET;
@@ -2531,7 +2542,7 @@ send_unicast(dstip, sdhcp)
   struct msghdr msg;
   struct iovec bufvec[1];
   int bufsize = DFLTDHCPLEN;
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   int on;
 #endif
 
@@ -3077,7 +3088,7 @@ handle_str(buf, param)
   }
 
   bcopy(OPTBODY(buf), str, OPTLEN(buf));
-  str[OPTLEN(buf)] = '\0';
+  str[(unsigned int)OPTLEN(buf)] = '\0';
   buf += OPTLEN(buf) + 1;
   return(0);
 }
